Belgelerim/ceng_491/implementation/doxygen/TraffEdu_Developers_Manual_Reference_ToSource/SPLITTER.CPP

Go to the documentation of this file.
00001 // Splitter.cpp : implementation file
00002 //
00003 /*
00004 * The class is generated by the help of some opensource code,
00005 * to get a splitter class with more functionalities you can search for the 
00006 * name C4WaySplitter or for just splitter in search engines.
00007 **/
00008 #include "stdafx.h"
00009 #include "TraffEdu.h"
00010 #include "Splitter.h"
00011 
00012 #ifdef _DEBUG
00013 #define new DEBUG_NEW
00014 #undef THIS_FILE
00015 static char THIS_FILE[] = __FILE__;
00016 #endif
00017 
00019 // C4WaySplitter
00020 
00021 C4WaySplitter::C4WaySplitter()
00022 {
00023         // for the background brush and the SetBkColor too...
00024         m_BkColor = RGB(128,128,128);
00025         m_ListBoxBkBrush.CreateSolidBrush(m_BkColor);
00026         m_nHiddenCol=-1;
00027         m_nHidedCol=-1; // hided column number, -1 if all columns are shown
00028         m_nHidedRow=-1; // hided row number, -1 if all columns are shown 
00029 }
00030 
00031 C4WaySplitter::~C4WaySplitter()
00032 {
00033         m_ListBoxBkBrush.DeleteObject();
00034 }
00035 
00036 
00037 BEGIN_MESSAGE_MAP(C4WaySplitter, CSplitterWnd)
00038         //{{AFX_MSG_MAP(C4WaySplitter)
00039         ON_WM_CTLCOLOR()
00040         //}}AFX_MSG_MAP
00041 END_MESSAGE_MAP()
00042 
00043 HBRUSH C4WaySplitter::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
00044 {
00045         HBRUSH hbr = CSplitterWnd::OnCtlColor(pDC, pWnd, nCtlColor);
00046         
00047         if( nCtlColor == CTLCOLOR_LISTBOX &&
00048                 pWnd->GetDlgCtrlID() == IdFromRowCol(1,0) )
00049           {
00050                 pDC->SetBkColor(m_BkColor);
00051                 pDC->SetTextColor(RGB(255,255,255));
00052                 return ( HBRUSH ) m_ListBoxBkBrush.GetSafeHandle();
00053           }
00054         // TODO: Return a different brush if the default is not desired
00055         return hbr;
00056 }
00057 
00058 BOOL C4WaySplitter::ReplaceView(CRuntimeClass* pRTClass)
00059 {
00060         TRACE("inside Splitter::ReplaceView\n");
00061         CTraffEduDoc* pDoc = ((CTraffEduApp*)AfxGetApp())->m_pDoc;
00062         if(!pDoc)  //most likely a problem reading in file
00063         {
00064                 AfxMessageBox("There was a problem reading the file, please open another one.");
00065                 return FALSE;
00066         }
00067 
00068         CWnd* pWndLeftPane = GetPane(0,0);
00069         if(pWndLeftPane->IsKindOf(pRTClass))
00070            return FALSE; //View is already selected, so don't need to destroy it and then create it again.
00071 
00072     //Set flag so that document will not be deleted when view is destroyed.
00073         //m_bAutoDelete is a non-documented member of CDocument.
00074         pDoc->m_bAutoDelete = FALSE;    
00075 
00076     //Delete old view: 
00077         pWndLeftPane->DestroyWindow();  
00078 
00079         //Create new view:
00080         CCreateContext context;
00081         context.m_pNewViewClass   = pRTClass;
00082         context.m_pCurrentDoc     = pDoc;
00083         context.m_pNewDocTemplate = NULL;
00084         context.m_pLastView       = NULL;
00085         context.m_pCurrentFrame   = NULL;
00086         CreateView(0, 0, pRTClass, CSize(120,120), &context);
00087 
00088         CView* pNewView = (CView*)GetPane(0,0);
00089         RecalcLayout(); 
00090         pNewView->OnInitialUpdate();
00091         pNewView->SendMessage(WM_PAINT);
00092 
00093         return TRUE;
00094 }

Generated on Sun May 28 18:54:09 2006 for TraffEdu by  doxygen 1.4.6-NO